package com.itlong.cloud.operate.resource;

import com.itlong.cloud.POJO.VO.operate.OperateAddressVO;
import com.itlong.cloud.POJO.VO.operate.OperateAreaAddressVO;
import com.itlong.cloud.POJO.VO.operate.OperateCountryAddressVO;
import com.itlong.cloud.equip.operate.IOperateAddressManageServiceClient;
import com.itlong.cloud.operate.service.IOperateAddressManageService;
import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <desc>
 * DEMO示例。
 * <desc/>
 *
 * @createDate 2017/10/23.
 */
@RestController
public class OperateAddressManageServiceResource implements IOperateAddressManageServiceClient {

    private static final Logger LOG = LoggerFactory.getLogger(OperateAddressManageServiceResource.class);

    @Autowired
    IOperateAddressManageService iOperateAddressManageService;

    /**
     * <desc>
     *      获取国家信息。
     * <desc/>
     *
     * @param
     * @return 返回国家信息列表（国家ID和国际名称）
     * @author shengen.T
     * @createDate 2017/10/23
     */
    @Override
    @RequestMapping(path="/operate/addressManage/getCountry")
    public List<OperateCountryAddressVO> getCountry() throws Exception{
        return iOperateAddressManageService.getCountryList();
    }

    /**
     * <desc>
     *      获取区域列表。
     * <desc/>
     *
     * @param
     * @return
     * @author shengen.T
     * @createDate 2017/10/23
     */
    @Override
    @RequestMapping(path="/operate/addressManage/getArea/{countryId}",method = RequestMethod.GET)
    public List<OperateAreaAddressVO> getArea(@PathVariable("countryId") String countryId) throws Exception{
        return iOperateAddressManageService.getAreaList(countryId);
    }

    /**
     * <desc>
     * 获取某个地址的直接下属地址
     * <desc/>
     *
     * @param parentAddressId 父地址
     * @return
     * @author Chunjian.G
     * @createDate 2017-12-05
     */
    @Override
    @RequestMapping(path="/operate/addressManage/getAddress",method = RequestMethod.POST)
    public List<OperateAddressVO> getAddress(@RequestParam("parentAddressId")String parentAddressId) throws Exception {
        return iOperateAddressManageService.getAddressList(parentAddressId);
    }

}
